package com.csea.app.controller;
import com.csea.app.model.vo.idiom.SearchPublicIdiomReqVO;
import com.csea.app.model.vo.idiom.SearchPublicIdiomRspVO;
import com.csea.app.service.PublicIdiomService;
import com.csea.common.aspect.ApiOperationLog;
import com.csea.common.domain.dos.PublicIdiomDo;
import com.csea.common.utils.Response;
import io.swagger.v3.oas.annotations.Operation;
import io.swagger.v3.oas.annotations.tags.Tag;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.annotation.Validated;
import org.springframework.web.bind.annotation.*;

import java.util.List;

@RestController
@RequestMapping("/public/idiom")
@Tag(name = "公共词语")
public class PublicIdiomController {
    @Autowired
    private PublicIdiomService publicIdiomService;

    @PostMapping("/search")
    @ApiOperationLog(description = "查询公共词语")
    @Operation(summary = "查询公共词语")
    public Response<List<SearchPublicIdiomRspVO>> search(@RequestBody @Validated SearchPublicIdiomReqVO searchPublicIdiomReqVO) {
        return publicIdiomService.searchPublicIdiomByKeyword(searchPublicIdiomReqVO);
    }

    @GetMapping("/search/{keyword}")
    @ApiOperationLog(description = "查询公共词语")
    @Operation(summary = "查询公共词语")
    public Response<PublicIdiomDo> search(@PathVariable String keyword) {
        return publicIdiomService.searchPublicIdiomByCoze(keyword);
    }
}
